package com.itextpdf.local.ess.Signature;

import com.itextpdf.local.ess.predefine.PictureType;
import com.itextpdf.local.ess.predefine.SealStandard;
import com.itextpdf.local.ess.predefine.SealStruct;
import com.itextpdf.local.ess.predefine.UKType;

public class SealBuilder extends SealBuilderIn{

    SealStruct sealStruct = new SealStruct();

    @Override
    public SealBuilder SealId(String sealId) {
        sealStruct.setSealId(sealId);
        return this;
    }
    @Override
    public SealBuilder SealName(String sealName) {
        sealStruct.setSealName(sealName);
        return this;
    }
    @Override
    public SealBuilder Img(int width,int height,byte[] imgByte,PictureType picType){
        sealStruct.setWidth(convertCoordinate(width));
        sealStruct.setHeight(convertCoordinate(height));
        sealStruct.setImgByte(imgByte);
        sealStruct.setPicType(picType);
        return this;
    }

    @Override
    public SealBuilder SealStandard(SealStandard sealStandard) {
        sealStruct.setSealStandard(sealStandard);
        return this;
    }

    @Override
    public SealBuilder CertByte(byte[] certByte) {
        sealStruct.setCertByte(certByte);
        return this;
    }

    @Override
    public SealBuilder Pfx(byte[] pfxByte,String pfxPsw) {
        sealStruct.setPfxByte(pfxByte);
        sealStruct.setPfxPsw(pfxPsw);
        return this;
    }

    @Override
    public SealBuilder Uk(UKType ukType,String ukID) {
        sealStruct.setUkType(ukType);
        sealStruct.setUkID(ukID);
        return this;
    }

    @Override
    public SealBuilder AsnSeal(byte[] asnSeal) {
        sealStruct.setAsnSeal(asnSeal);
        return this;
    }

    @Override
    public SealStruct build() {
        return sealStruct;
    }

    public static int convertCoordinate(int mm) {
        return (595*mm)/210;
    }
}
